package BuddyTemplate;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author kpc1
 */

public class AdaptiveEngine {
    
    QuestionInterface QI;
    int Score;
    
    
    public AdaptiveEngine(QuestionInterface TheQuestionCollection)
    {

        QI = TheQuestionCollection;
    }
            
    

    public void setNewDifficulty(int x)
    {
    
        QI.setDifficulty(x);
        
    }
    
    public void checkDifficulty(int Score)
    {
        int difficulty = QI.getDifficulty();
        
        if(difficulty == 0)
        {
            if(Score >= 10)
            {
                setNewDifficulty(1);
            }
   
        }
        
        else if(difficulty == 1)
        {
            if(Score >= 20)
            {
                setNewDifficulty(difficulty + 1);
            }
            
            else if(Score <= 5)
            {
                setNewDifficulty(difficulty - 1);
            }
        }
        
        else if(difficulty == 2)
        {
            if(Score <= 15)
            {
                setNewDifficulty(difficulty - 1);
            }
        }
    }
    
    public void checkFinish(QuestionInterface QI)
    {
        if(QI.isFinal())
        {
            int difficulty = QI.getDifficulty();
            setNewDifficulty(difficulty + 1);
               
        }
    }
}